package top.lshaci.learning.netty.http;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.http.HttpServerCodec;

/**
 * HttpServerInitializerTest
 *
 * @author lshaci
 * @since 1.0.0
 */
public class HttpServerInitializerTest extends ChannelInitializer<SocketChannel> {

    @Override
    protected void initChannel(SocketChannel ch) throws Exception {
        // 得到管道
        ChannelPipeline pipeline = ch.pipeline();
        // 向管道添加处理器
        // 编解码处理器 HttpServerCodec ; netty 提供的 http server 编解码器
        // HttpServerCodec : Codec => coder decoder
        pipeline.addLast("MyHttpServerCodec", new HttpServerCodec());
        // 添加自定义的处理器
        pipeline.addLast("MyHttpServerHandler", new HttpServerHandlerTest());
    }
}
